<?php
namespace other\tongtu;
use App\Models\Tongtu;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
use Illuminate\Support\Facades\Log;
use other\ShopingConn;
use other\Table;
use think\Db;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\Exception;
use think\exception\DbException;

/**
 * 通途基类
 */
class OrderApi extends BaseC
{
    /**
     * 上传通途订单
     * @param array $orderParams
     * @return mixed|null
     */
    public function orderImport(array $orderParams)
    {
        return self::post(
            '/openapi/tongtool/orderImport',
            [
                'query'=>[
                    'order'=>$orderParams,
                    'merchantId'=>self::MERCHANT_ID
                ],
            ]
        );
    }

    /**
     * 根据订单查询物流单号
     * @see https://open.tongtool.com/apiDoc.html#/?docId=3b3cceec8fe04e6db44da17ec4b38f08
     * @param $orderIds
     * @param int $page
     * @param int $pageSize
     * @return mixed|null
     */
    public function trackingNumberQuery($orderIds, int $page = 1, int $pageSize = 100)
    {
        return self::post('/openapi/tongtool/trackingNumberQuery',[
            'query'=>[
                'merchantId'=>self::MERCHANT_ID,
                'orderIds'=>$orderIds,
                'pageNo'=>$page,
                'pageSize'=>$pageSize,
            ]
        ]);
    }

    /**
     * 订单查询
     * @param $queryData
     * @see https://open.tongtool.com/apiDoc.html#/?docId=f4371e5d65c242a588ebe05872c8c4f8
     * @return mixed|null
     */
    public function orderQuery($queryData)
    {
        $queryData['merchantId'] = self::MERCHANT_ID;
        return self::post(
            '/openapi/tongtool/ordersQuery',
            [
                'query'=>$queryData,
            ]
        );
    }
}
